//
//  ToDo.swift
//  RX
//
//  Created by iOS开发 on 2019/2/13.
//  Copyright © 2019 iOS开发. All rights reserved.
//

import UIKit

class ToDo: NSObject {
    var id : UInt?
    var title : String?
    var completed : Bool
    
    init(id : UInt, title: String, completed : Bool) {
        self.id = id
        self.title = title
        self.completed = completed
    }
    
    required init?(json:[String : Any]) {
        guard
            let todoId = json["id"] as? UInt,
            let title = json["title"] as? String ,
            let completed = json["completed"] as? Bool
        else {
            return nil
        }
        
        self.id = todoId
        self.title = title
        self.completed = completed
    }
    
    override var description: String {
        return "ID : \(self.id ?? 0) "
            + "title \(self.title ?? "")"
            + "completed : \(self.completed)"
    }
}
